<template>
  <!-- 音乐列表 -->
  <div>
    <table>
      <tr v-for="(item, index) in arr" :key="item.id">
        <td class="tdOne">
          {{ index }} <span @click="PlayClick(item)"></span>
        </td>
        <router-link
          tag="td"
          :to="{ name: 'musicdetail', query: { id: item.id } }"
          class="tdTwo"
          >{{ item.name }} <span></span
        ></router-link>
        <td class="tdThere">
          <p class="musicTime">{{ (item.dt / 1000 / 60).toFixed(2) }}</p>
          <div class="operationBox">
            <span class="play" @click="pushMusicAction(item)"></span>
            <span class="Collection" @click="collectionBtn(item.id)"></span>
            <span class="forward"></span>
            <span class="download"></span>
          </div>
        </td>
        <td class="tdFour">{{ item.al.name }}</td>
      </tr>
    </table>
  </div>
</template>
<script>
import { mapActions } from "vuex";
export default {
  props: {
    arr: {
      type: Array,
      default: () => {
        return [];
      },
    },
  },
  data() {
    return {
      content: [],
      count: 0,
    };
  },
  methods: {
    ...mapActions("musicStore", ["unshiftMusic", "pushMusicAction"]),
    ...mapActions("songSheetStore", [
      "set_change_songSheetBoxIsHide",
      "set_change_musicId",
    ]),
    async PlayClick(item) {
      //直接点击播放当前音乐
      await this.unshiftMusic({ data: item, that: this });
      // this.$bus.$emit("playCurrentMusic");
    },
    //收藏按钮
    collectionBtn(id) {
      this.set_change_musicId(id);
      this.set_change_songSheetBoxIsHide(true);
    },
  },
};
</script>

<style lang="scss" scoped>
table {
  width: 100%;
  border-collapse: collapse;
  tr {
    width: 100%;
    &:hover {
      .operationBox {
        display: block !important;
      }
      .musicTime {
        display: none;
      }
    }
    .tdOne {
      width: 74px;
      padding: 6px 10px;
      line-height: 18px;
      text-align: left;
      color: #999;
      span {
        float: right;
        width: 17px;
        height: 17px;
        cursor: pointer;
        background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -103px;
      }
    }
    .tdTwo {
      padding: 6px 10px;
    }
    .tdThere {
      color: #666;
      width: 100px;
      .operationBox {
        display: none;
        span {
          display: inline-block;
          width: 18px;
          height: 16px;
          vertical-align: middle;
          margin-left: 5px;
        }
        .play {
          width: 13px;
          height: 13px;
          background: url("./../../assets/imges/btnIconTwo.png") no-repeat 0 -700px;
        }
        .Collection {
          background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -174px;
        }
        .forward {
          background: url("./../../assets/imges/iconTwo.png") no-repeat 0 -195px;
        }
        .download {
          background: url("./../../assets/imges/iconTwo.png") no-repeat -81px -174px;
        }
      }
    }
    .tdFour {
      width: 20%;
      padding: 6px 10px;
      line-height: 18px;
      text-align: left;
      color: #333;
    }
    &:nth-of-type(even) {
      background: #f7f7f7;
    }
  }
}
</style>